import axios from 'axios';
import { loginreq, req, reqAdd, reqDian} from './axiosFun';

// 登录接口 
export const login = (params) => { 
    return loginreq("post", "/api/v1/system/login", params) };
// 获取用户菜单
export const menu = (params) => { return axios.get("/api/menu?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 退出接口
export const loginout = () => { return axios.delete("/api/login?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 用户管理 
 **/
// 用户管理-获取用户列表
export const userList = (params) => { return req("post", "/api/User/list", params) };
// 用户管理-保存（添加编辑）
export const userSave = (params) => { return req("post", "/api/User/save", params) };
// 用户管理-删除用户
export const userDelete = (params) => { return axios.delete("/api/User/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 用户管理-重置密码
export const userPwd = (params) => { return req("post", "/api/User/pwd", params) };
// 用户管理-修改状态
export const userLock = (params) => { return axios.get("/api/User/lock?userId=" + params.userId + "&lock=" + params.lock + "&token=" + localStorage.getItem('logintoken')) };
// 用户管理-数据权限
export const UserDeptTree = (params) => { return axios.get("/api/UserDept/tree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 用户管理-数据权限保存
export const UserDeptSave = (params) => { return req("post", "/api/UserDept/save", params) };
// 用户管理-获取部门设置
export const UserDeptdeptTree = (params) => { return axios.get("/api/UserDept/deptTree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 用户管理-保存部门设置
export const UserChangeDept = (params) => { return req("post", "/api/User/change/dept", params) };
// 用户管理-用户下线
export const userExpireToken = (params) => { return req("get", "/api/User/expireToken/" + params, {}) };
// 用户管理-刷新缓存
export const userFlashCache = (params) => { return req("get", "/api/User/flashCache/" + params, {}) };

/**
 * 菜单管理
 **/
// 菜单管理-获取菜单Module/list
export const ModuleList = () => { return req("post", "/api/Module/list") };
// 菜单管理-根据菜单获取数据
export const ModuleGet = (params) => { return axios.get("/api/Module/get/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 菜单管理-获取父级菜单Module/nodes
export const ModuleNodes = (params) => { return req("post", "/api/Module/nodes", params) };
// 菜单管理-修改菜单
export const ModuleSave = (params) => { return req("post", "/api/Module/save", params) };
// 菜单管理-删除菜单
export const ModuleDelete = (params) => { return axios.delete("/api/Module/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 角色管理 
 **/
// 角色管理-获取角色列表
export const roleList = (params) => { return req("post", "/api/Role/list", params) };
// 角色管理-保存（添加编辑）
export const roleSave = (params) => { return req("post", "/api/Role/save", params) };
// 角色管理-删除角色
export const roleDelete = (params) => { return axios.delete("/api/Role/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 角色管理-菜单权限（获取）
export const RoleRightTree = (params) => { return axios.get("/api/RoleRight/tree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 角色管理-菜单权限（保存）
export const RoleRightSave = (params) => { return req("post", "/api/RoleRight/save", params) };
/**
 * 
 * @param {首页} params 
 * @returns 
 */
// 首页-系统信息
export const systemList = (params) => { return req("get", "/api/v1/system/status", params) };
/**
 * 通讯接口
 **/
// 通讯接口-获取公司列表
export const deptList = (params) => { return req("get", "/api/v1/device/commInterface", params) };
// 通讯接口-添加
export const deptSave = (params) => { return reqAdd("post", "/api/v1/device/commInterface", params) };
// 通讯接口-编辑
export const deptUpdate = (params) => { return reqAdd("put", "/api/v1/device/commInterface", params) };
// 通讯接口-删除公司
export const deptDelete = (params) => { return req("DELETE","/api/v1/device/commInterface" , params) };

/**
 * 从机设备 
 **/
// 从机设备-获取从机设备列表
export const variableList = (params) => { return req("get", "/api/v1/device/slave", params) };
// 从机设备-获取从机设备类型的下拉框列表
export const typeList = (params) => { return req("get", "/api/v1/device/slave/type", params) };
// 从机设备-添加从机设备
export const variableSave = (params) => { return req("post", "/api/v1/device/slave", params) };
// 从机设备-编辑从机设备
export const variableEdit = (params) => { return req("put", "/api/v1/device/slave", params) };
// 从机设备-删除从机设备
export const variableDelete = (params) => { return req("DELETE", "/api/v1/device/slave", params) };
// 从机设备-使能从机设备
export const variableOpen = (params) => { return req("post", "/api/v1/device/slave/enable", params) };

/**
 * 点表 
 **/
// 点表-获取点表内容列表
export const permissionList = (params) => { return reqDian("get", "/api/v1/nodeTable/", params) };
// 点表-获取点表下拉框内容列表
export const dianAllList = (params) => { return reqDian("get", "/api/v1/nodeTable/dataLimit", params) };
// 点表-编辑
export const permissionUpdate = (params) => { return req("PUT", "/api/v1/nodeTable/", params) };
// 点表-导出表格
export const exportList = (params) => { return req("get", "/api/v1/nodeTable/opt?devId=dev1", params) };
// 点表-删除权限
export const permissionDelete = (params) => { return axios.delete("/api/Permission/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 点表-获取权限
export const roleDropDown = () => { return axios.get("/api/Role/dropDown/all?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 点表-配置权限
export const RolePermission = (params) => { return req("post", "/api/RolePermission/save", params) };

/**
 * 监控
 **/
// 监控-查询监控数据
export const controlList = (params) => { return reqDian("get", `/api/v1/node/val?devId=${params}`) };
// 监控-修改监控数据
export const controlUpdate = (params) => { return req("put", "/api/v1/node/val",params) };